package com.jdk.mode.struct;

/**
 * @author jukg
 * @date 2023/08/25 16:53
 * @description 外观模式 类似于控制面板
 */
public class Facade {

    public static void main(String[] args) {
        Unit u1 = new Unit("cpu");
        Unit u2 = new Unit("memory");
        Unit u3 = new Unit("driver");
        new UnitFacade(u1, u2, u3);
    }



}

abstract class Process{
    String name;

    public Process(String name) {
        this.name = name;
    }
    void process(){
        System.out.println(name + " loading.....");
        System.out.println(name + " finished!");
    }
}


class Unit extends Process {

    public Unit(String name) {
        super(name);
    }
}

class UnitFacade{

    public UnitFacade(Unit... unit) {
        for(Unit u: unit){
            u.process();
        }
    }
}
